package com.yisen.dasan.mq;

import com.alibaba.fastjson.JSONObject;
import com.yisen.dasan.service.MailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;

/**
 * @AuthorList: LiuYiSen
 * @Date: 2020/10/25 13:51
 */
//@Component
//public class RegisterConsumer {
//    @Autowired
//    private MailService mailService;
//    private static final Logger logger = LoggerFactory.getLogger(RegisterConsumer.class);
//    @RabbitListener(queuesToDeclare = @Queue(value = "register"))
//    public void receive1(String message){
//        JSONObject jsonObject = JSONObject.parseObject(message);
//        try {
//            mailService.userRegister(jsonObject.getString("key"), jsonObject.getString("mail"));
//        } catch (MessagingException e) {
//            e.printStackTrace();
//            logger.info("邮件发送失败："+message);
//        }
//    }
//    @RabbitListener(queuesToDeclare = @Queue(value = "register"))
//    public void receive2(String message){
//        JSONObject jsonObject = JSONObject.parseObject(message);
//        try {
//            mailService.userRegister(jsonObject.getString("key"), jsonObject.getString("mail"));
//        } catch (MessagingException e) {
//            e.printStackTrace();
//            logger.info("邮件发送失败："+message);
//        }
//    }
//}
